package io.read_file;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/05/09 19:50
 **/
public class ReadTest {
    public static void main(String[] args) throws IOException {
        try (InputStream is = new FileInputStream("src/io/read_file/hello.txt")){
            //Scanner sc = new Scanner(is,"UTF-8");
            // GBK国标
            Scanner sc = new Scanner(is,"GBK");
            while (sc.hasNext()){
                // 读到下一个空格或回车
                System.out.println(sc.next());
            }
        }

        try(InputStream is = new FileInputStream("src/io/read_file/hello.txt")){
            Scanner s = new Scanner(is, "utf-8");
            while (s.hasNextLine()){
                System.out.println(s.nextLine());
            }
        }
    }
}